﻿using System;
using System.Collections.Generic;

namespace 动态为类型添加属性
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("动态为类型添加属性");
            dynamic dynamicModel = new DynamicModel();
            
            List<string> keyList = new List<string>()
            {
                "Name",
                "Age",
                "Hobby"
            };

            List<object> valueList = new List<object>()
            {
                "Mary",
                18,
                "Writing"
            };

            for(int i = 0; i < keyList.Count && i < valueList.Count; i++)
            {
                dynamicModel.PropertyName = keyList[i];
                dynamicModel.Property = valueList[i];
            }

            Console.WriteLine($"Name:{dynamicModel.Name}");
            Console.WriteLine($"Age:{dynamicModel.Age}");
            Console.WriteLine($"Hobby:{dynamicModel.Hobby}");
        }
    }
}
